package com.jxpanda.spring.module.auth.core.authentication.token;

import com.jxpanda.spring.module.auth.endpoint.OAuth2Request;
import lombok.Getter;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.client.registration.ClientRegistration;

@Getter
public class UserDetailsAuthenticationToken<U extends UserDetails> extends CollaborativeAuthenticationToken {

    private final U userDetails;

    public UserDetailsAuthenticationToken(OAuth2Request oAuth2Request, ClientRegistration clientRegistration, U userDetails) {
        super(oAuth2Request, clientRegistration);
        this.userDetails = userDetails;
        this.setAuthenticated(userDetails != null);
    }


    @Override
    public Object getCredentials() {
        return "";
    }

    @Override
    public Object getPrincipal() {
        return userDetails;
    }

}
